<?php

/**
 * CategoriaController - The default controller class
 * 
 * @author
 * @version 
 */

class UsuarioController extends AppBaseController
{
	/**
	 * The default action - show the home page
	 */
	public function init()
	{
		parent::init();
	}
	
    public function loginAction()
    {
    	
	    if($this->_request->isPost())
		{
			
			$usuario = new usuario();
			$array = $usuario->login($_POST['email'],$_POST['senha']);
			if(sizeof($array)>0)
			{
				$sessao = new Zend_Session_Namespace('certificadospp');
				$sessao->logado = true;
				$sessao->idusuario 					= $array[0]['idusuario'];
				$sessao->nomecompleto 				= $array[0]['email'];
				$sessao->nivel		 				= $array[0]['nivel'];
		
				$this->_redirect('/logado');
			}
		}
    }
    
    public function logoutAction()
    {
    	Zend_Session::destroy();
		$this->_redirect('/');
		exit();
    }
}
